package com.demo.blog.config;

import com.demo.blog.common.Constants;
import com.demo.blog.model.Result;
import lombok.extern.slf4j.Slf4j;
import org.springframework.web.bind.annotation.ControllerAdvice;
import org.springframework.web.bind.annotation.ExceptionHandler;
import org.springframework.web.bind.annotation.ResponseBody;

/**
 * Created with IntelliJ IDEA.
 * Description:
 * User: 22652
 * Date: 2024-07-24
 * Time: 11:22
 */


@ResponseBody
@ControllerAdvice
@Slf4j
public class ErrorAdvice {
    @ExceptionHandler
    public Result errorHandler(Exception e){

        Result result = new Result<>();
        result.setErrorMsg("内部发生错误, 请联系管理员");
        result.setCode(Constants.RESULT_FAIL);
        return result;
    }
}